package com.kiln.juxingqs.dialog

import androidx.databinding.ObservableField
import androidx.fragment.app.FragmentActivity
import client.global.commlib.toast.toast
import client.global.commlib.utils.StoreUtil
import com.kiln.juxingqs.R
import com.kiln.juxingqs.api.bean.UserInfo
import com.kiln.juxingqs.databinding.DialogEditusernameBinding
import com.tzstore.oo.dialog.CenterDialog

class EditUserNameDialog(context: FragmentActivity) :
    CenterDialog<DialogEditusernameBinding>(context) {

    override fun getV(): Int {
        return R.layout.dialog_editusername
    }

    val nickname = ObservableField<String>("")

    override fun postBinding() {
        binding.event = this
        StoreUtil.getBean<UserInfo>(context)?.let {
            nickname.set("${it.nickname}")
        }
    }

    var ok: ((txt: String) -> Unit)? = null

    fun oneType() {
        if (nickname.get().isNullOrEmpty()) {
            toast("请输入内容")
            return
        }
        cancel()
        ok?.invoke(nickname.get()!!)
    }

}